﻿@{
    ViewBag.Title = "公司管理";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}

<table id="dg" class="easyui-datagrid"  style="width:100%; height: 600px;"
       url="/BasicManage/GetLKCompanyPageList" toolbar="#tb" title="公司列表" " rownumbers="true" pagination="true"
       pagelist="[15]" fitcolumns="true" singleselect="true">
    <thead>
        <tr>
            <th field="CompanyCode" align="right" width="10%">
                公司编码
            </th>
            <th field="CompanyName" align="right" width="10%">
                公司名称
            </th>
            <th field="Address" align="right" width="10%">
                地址
            </th>
            <th field="Moblie" align="right" width="10%">
                联系电话
            </th>
            <th field="Phone" align="right" width="10%">
                座机
            </th>
        </tr>
    </thead>
</table>
<div id="tb" style="padding: 3px; height: auto;">
    <span>公司：</span>
    <input id="Company" class="easyui-textbox " data-options="validType:'length[1,50]',prompt:'公司或公司编号'" style="width: 173px; height: 30px;" />
    <div>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addLKCompany()">新建</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editLKCompany()">编辑</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" onclick="delLKCompany()">删除</a>
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="doSearch()">查询</a>
    </div>
</div>
<div id="dlg" class="easyui-dialog" title="新增" data-options="iconCls:'icon-save'"
     closed="true" style="width: 850px; height: 450px; padding: 10px 20px" buttons="#dlg-buttons" modal="true">
    <form id="fm" method="post" novalidate>
        <input type="hidden" name="Id" />
        <div class="fitem">
            <label>
                公司编码:
            </label>
            <input name="CompanyCode" id="CompanyCode" class="easyui-textbox" style="width: 173px; height: 30px;" />
            <label>
                公司名称:
            </label>
            <input name="CompanyName" id="CompanyName" class="easyui-textbox" data-options="required: true" style="width: 173px; height: 30px;" />
        </div>
        <div class="fitem">
            
            <label>
                联系电话:
            </label>
            <input name="Moblie" id="Moblie" class="easyui-textbox" data-options="validType:'length[1,11]',prompt:'1~11位的数字'" style="width: 173px; height: 30px;" />
            <label>
                座机:
            </label>
            <input name="Phone" id="Phone" class="easyui-textbox" style="width: 173px; height: 30px;" />
        </div>
        <div class="fitem">
            <label>
                地址:
            </label>
            <input name="Address" class="easyui-textbox" data-options="validType:'length[1,100]',prompt:'1~100位的汉字'" style="width: 550px; height: 30px;" autocomplete="off" />
        </div>

    </form>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="saveLKCompany()">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>


<script language="javascript" type="text/javascript">
    $(function () {
        
    });

    function doSearch() {
        $('#dg').datagrid('load', {
            Company: $('#Company').textbox('getValue')
        });
    }

    function addLKCompany() {
        $('#fm').form('clear');
        $('#dlg').dialog('open');
        url = '/BasicManage/AddLKCompany';
    }

    function editLKCompany() {
        var row = $('#dg').datagrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要编辑的信息?');
            return;
        }
        $('#dlg').dialog('open').dialog('setTitle', '编辑');
        $.messager.progress({
            title: '请稍后',
            msg: '数据加载中...',
        });
        window.setTimeout(function () {
            $('#fm').form('load', row);
            $.messager.progress('close');
        }, 1000);

        url = "/BasicManage/EditLKCompany";
    }

    function delLKCompany() {
        var row = $('#dg').datagrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要删除的信息?');
            return false;
        }
        $.messager.confirm('提示信息', '您确认要删除吗?', function (r) {
            if (!r) { return false; }
            $.post("/BasicManage/DeleteLKCompany", { id: row.Id }, function (json) {
                Helper.Show(json.Msg);
                if (json.Success) {
                    doSearch();
                }
            });
        });
    }

    function saveLKCompany() {
        $('#fm').form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (json) {
                var json = eval('(' + json + ')');
                Helper.Show(json.Msg);
                if (json.Success) {
                    $('#fm').form('clear');
                    $('#dlg').dialog('close');
                    $('#dg').datagrid('reload');
                }
            }
        });
    }

    function formatter_IsValid(value, rowData, rowIndex) {
    return rowData.IsValid ? '启用' : '停用';
}
</script>



